<template>
  <div class="common-layout__create" v-title data-title="创作中心">
    <el-container>
      <el-aside width="220px">
        <el-affix :offset="80">
          <div class="left-nav scroll">
            <h5 class="mb-2">创作中心</h5>
            <el-menu
              :default-active="menuIndex"
              router
              class="el-menu-vertical-demo"
            >
              <el-menu-item index="/platform/upload">
                <el-icon><UploadFilled /></el-icon>
                <span>投稿</span>
              </el-menu-item>
              <el-menu-item index="/platform/manage">
                <el-icon><Management /></el-icon>
                <span>稿件管理</span>
              </el-menu-item>
              <!-- <el-menu-item index="/platform/data">
                <el-icon><TrendCharts /></el-icon>
                <span>数据中心</span>
              </el-menu-item> -->
              <el-sub-menu index="4">
                <template #title>
                  <el-icon><Flag /></el-icon>
                  <span>互动管理</span>
                </template>
                <el-menu-item-group>
                  <el-menu-item index="/platform/comment">
                    评论管理
                  </el-menu-item>
                  <el-menu-item index="/platform/danmaku">
                    弹幕管理
                  </el-menu-item>
                </el-menu-item-group>
              </el-sub-menu>
            </el-menu>
          </div>
        </el-affix>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </div>
</template>

<script lang="ts" setup>
import { ref, watch, onUnmounted } from "vue";
import {
  UploadFilled,
  Management,
  TrendCharts,
  Flag,
} from "@element-plus/icons-vue";
import { useRouter } from "vue-router";

const menuIndex = ref<string>("/platform/upload")
const route = useRouter();
const watchPath = watch(
  () => route.currentRoute.value.fullPath,
  (newV, oldV) => {
    console.log(newV);
    menuIndex.value = newV
  },
  { immediate: true }
);

onUnmounted(() => {
  watchPath();
});
</script>

<style lang="scss" scoped>
.common-layout__create {
  background-color: #ffffff;

  .left-nav {
    position: relative;
    margin-left: 10px;
    background-color: white;
    height: calc(100vh - 100px);
    border-radius: 10px;
    box-shadow: 0 0 10px #e0e0e0;
    font-family: YouYuan, serif;
    font-weight: 700;
    color: #555555;

    h5 {
      font-size: 15px;
      font-weight: 700;
      margin-top: 10px;
      margin-left: 20px;
    }
  }
  .el-main > * {
    min-height: calc(100vh - 110px);
    width: 90%;
    margin: 0 auto;
    position: relative;
    border-radius: 10px;
  }
}
</style>
